package nl.unimaas.micc.umsnooker.domain;

import java.util.Collection;

import nl.unimaas.micc.umsnooker.domain.Ball.BallState;
import nl.unimaas.micc.umsnooker.math.BairstowSolver;
import nl.unimaas.micc.umsnooker.math.Transformation3D;
import nl.unimaas.micc.umsnooker.math.XYRotationTrans3D;
import nl.unimaas.micc.umsnooker.simulation.event.CushionCollision;
import nl.unimaas.micc.umsnooker.simulation.event.Event;
import nl.unimaas.micc.umsnooker.simulation.physics.Physics;

import com.jme.math.FastMath;
import com.jme.math.Vector3f;

public class Cushion extends CollidableGameObject
{

	public enum Orientation
	{
		NORTH, EAST, SOUTH, WEST;
	}

	private Orientation orientation;
	private float length;
	
	public Cushion(Vector3f position,float length, Orientation orientation)
	{
		setPosition(position);
		setLength(length);
		this.orientation = orientation;
	}

	public void setLength(float length)
	{
		this.length = length;
	}
	
	public float getLength()
	{
		return this.length;
	}

	public Orientation getOrientation()
	{
		return orientation;
	}
	
	public void setOrientation(Orientation orientation)
	{
		this.orientation = orientation;
	}

	@Override
	public String toString()
	{
		return "[Cushion l:"+this.length +" o:"+ this.orientation + " " + super.toString() +"]";
	}

	@Override
	public Event findCollision(BilliardBall b)
	{
		double time = Physics.collisionTime(b, this);
		
		if(time>=0)
		{
			return new CushionCollision((float) (b.getTime() + time), b,this);
		}
		else
		{
			return null;
		}
	}


}
